Test Series - Data Structure

Test Number 58/115

Q: Which of the following is not the self balancing binary search tree?
A. AVL Tree
B. 2-3-4 Tree
C. Red – Black Tree
D. Splay Tree
Solution: 2-3-4 Tree is balanced search trees. But it is not a binary tree. So, it is not a self balancing binary tree. AVL tree, Red-Black Tree and Splay tree are self balancing binary search tree.
Q: The binary tree sort implemented using a self – balancing binary search tree takes ______ time is worst case.
A. O(n log n)
B. O(n)
C. O(n2)
D. O(log n)
Solution: The worst case running time of the binary tree sort is O(n2). But, the worst case running time can be improved to the O(n log n) using a self – balancing binary search tree.
Q: An AVL tree is a self – balancing binary search tree, in which the heights of the two child sub trees of any node differ by _________
A. At least one
B. At most one
C. Two
D. At most two
Solution: In an AVL tree, the difference between heights of the two child sub trees of any node is at most one. If the height differs by more than one, AVL tree performs rotations to balance the tree.
Q: Associative arrays can be implemented using __________
A. B-tree
B. A doubly linked list
C. A single linked list
D. A self balancing binary search tree
Solution: Associative arrays can be implemented using a self balancing binary search tree as the worst-case time performance of self – balancing binary search trees is O(log n).
Q: Self – balancing binary search trees have a much better average-case time complexity than hash tables.
A. True
B. False
C. ...
D. ...
Solution: For lookup, insertion and deletion hash table take O(1) time in average-case while self – balancing binary search trees takes O(log n). Therefore, hash tables perform better in average-case.
Q: Which of the following is a self – balancing binary search tree?
A. 2-3 tree
B. Threaded binary tree
C. AA tree
D. Treap
Solution: An AA tree, which is a variation of red-black tree, is a self – balancing binary search tree. 2-3 is B-tree of order 3 and Treat is a randomized binary search tree. A threaded binary tree is not a balanced tree.
Q: A self – balancing binary search tree can be used to implement ________
A. Priority queue
B. Hash table
C. Heap sort
D. Priority queue and Heap sort
Solution: Self-balancing binary search trees can be used to construct and maintain ordered lists, to achieve the optimal worst case performance. So, self – balancing binary search tree can be used to implement a priority queue, which is ordered list.
Q: In which of the following self – balancing binary search tree the recently accessed element can be accessed quickly?
A. AVL tree
B. AA tree
C. Splay tree
D. Red – Black tree
Solution: In a Splay tree, the recently accessed element can be accessed quickly. In Splay tree, the frequently accessed nodes are moved towards the root so they are quick to access again.
Q: The minimum height of self balancing binary search tree with n nodes is _____
A. log2(n)
B. n
C. 2n + 1
D.  2n – 1
Solution: Self – balancing binary trees adjust the height by performing transformations on the tree at key insertion times, in order to keep the height proportional to log2(n).
Q: Binary tree sort implemented using a self balancing binary search tree takes O(n log n) time in the worst case but still it is slower than merge sort.
A. True
B. False
C. ...
D. ...
Solution: The worst case performance of binary tree sort is O(n log n) when it is implemented using a self balancing binary search tree. Self balancing binary search trees perform transformations to balance the tree, which caused balancing overhead. Due to this overhead, binary tree sort is slower than merger sort.

You Have Score    /10